package com.xiaoc.bulldozer.common.service.impl;

import java.util.List;
import java.util.Date;
import java.util.Set;
import javax.annotation.Resource;

import com.xiaoc.bulldozer.common.dto.AwardPartnerDto;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import com.xiaoc.bulldozer.common.dao.AwardPartnerMapper;
import com.xiaoc.bulldozer.common.dto.AwardPartnerQueryDto;
import com.xiaoc.bulldozer.common.model.AwardPartner;
import com.xiaoc.bulldozer.common.service.AwardPartnerService;

/**
 * AwardPartner Service 实现类
 * 
 * @author Danfo Yam
 * 
 * @date 2018-08-24 15:47:58
 */
@Service("awardPartnerService")
public class AwardPartnerServiceImpl implements AwardPartnerService {

    @Resource
    private AwardPartnerMapper awardPartnerMapper;

    @Override
    public Integer getAwardPartnerCountByCondition(AwardPartnerQueryDto awardPartnerQueryDto) {
        return awardPartnerMapper.getAwardPartnerCountByCondition(awardPartnerQueryDto);
    }

    @Override
    public List<AwardPartner> getAwardPartnerListByCondition(AwardPartnerQueryDto awardPartnerQueryDto) {
        awardPartnerQueryDto.setPage(awardPartnerQueryDto.getPage());
        return awardPartnerMapper.getAwardPartnerListByCondition(awardPartnerQueryDto);
    }

    @Override
    public AwardPartner getAwardPartnerById(Integer id) {
        return awardPartnerMapper.getAwardPartnerById(id);
    }

    @Override
    public List<AwardPartner> getAllAwardPartnerList() {
        return awardPartnerMapper.getAllAwardPartnerList();
    }
    
    @Override
    public void save(AwardPartner awardPartner) {
        awardPartnerMapper.save(awardPartner);
    }

    @Override
    public void update(AwardPartner awardPartner) {
        awardPartnerMapper.update(awardPartner);
    }

    @Override
    public void deleteById(Integer id) {
        awardPartnerMapper.deleteById(id);
    }

    @Override
    public int getRegistSuccessCountByUserIdAndAwardIds(Integer userId, Set<Integer> awardIds) {
        if (userId == null || CollectionUtils.isEmpty(awardIds)){
            return 0;
        }
        return awardPartnerMapper.getRegistSuccessCountByUserIdAndAwardIds(userId,awardIds);
    }

    @Override
    public List<AwardPartnerDto> getPartnerListByAwardIdAndUserId(Integer awardId, Integer userId) {

        return awardPartnerMapper.getPartnerListByAwardIdAndUserId(awardId, userId);
    }


    @Override
    public List<AwardPartnerDto> getAllPartnerListByUserId(Integer userId) {

        return awardPartnerMapper.getAllPartnerListByUserId(userId);
    }

    @Override
    public AwardPartner getAwardPartnerByUserIdAndPartnerUserId(Integer userId, Integer partnerUserId) {

        return awardPartnerMapper.getAwardPartnerByUserIdAndPartnerUserId(userId,partnerUserId);
    }

    @Override
    public Integer getAllPartnerListCountByUserId(Integer userId) {

        return awardPartnerMapper.getAllPartnerListCountByUserId(userId);
    }

    @Override
    public Integer getSuccessPartnerByUserId(Integer partnerUserId) {
        return awardPartnerMapper.getSuccessPartnerByUserId(partnerUserId);
    }

    @Override
    public List<AwardPartnerDto> getAllPartnerListByUserIdAndPage(AwardPartnerQueryDto awardPartnerQueryDto) {
        awardPartnerQueryDto.setPage(awardPartnerQueryDto.getPage());
        return awardPartnerMapper.getAllPartnerListByUserIdAndPage(awardPartnerQueryDto);
    }

    @Override
    public AwardPartner getRecentAwardPartnerByPartnerUserId(Integer partnerUserId) {
        return awardPartnerMapper.getRecentAwardPartnerByPartnerUserId(partnerUserId);
    }

    @Override
    public int getAwardPartnerByAwardId(Integer awardId) {
        return awardPartnerMapper.getAwardPartnerByAwardId(awardId);
    }

    @Override
    public AwardPartner getRecentAwardPartnerByPartnerUserIdOne(AwardPartner awardPartner) {
        return awardPartnerMapper.getRecentAwardPartnerByPartnerUserIdOne(awardPartner);
    }

    @Override
    public List<AwardPartnerDto> getAwardPartnerList(Integer awardId) {
        return awardPartnerMapper.getAwardPartnerList(awardId);
    }
}
